<?php 
	// 将汉字转换成UTF-8
	function chinese2utf($chineseStr){
		$cur_encoding = mb_detect_encoding($chineseStr);
		if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8")){
			return $chineseStr;
		}else{
			return utf8_encode($chineseStr);
		}
	}
	
	// 发送邮件
	function sendMail($smtpserver,$smtpserverport,$smtpusermail,$smtpemailto,$smtpuser,$smtppass,$mailcontent,$mailtype){
		// 邮件主题
		$mailtitle = "天气预报";
		// 新建smtp协议，其中true是表示使用身份验证,否则不使用身份验证.
		$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
		//是否显示发送的调试信息
		$smtp->debug = false;
		$state = $smtp->sendmail($smtpemailto, $smtpusermail, $mailtitle, $mailcontent, $mailtype);
	
		if($state==""){
			echo "对不起，邮件发送失败！请检查邮箱填写是否有误。";
		}else{
			echo "恭喜！邮件发送成功！！";
		}
	}
?>